package com.arron.algorithm.leetcodetop100.贪心;

public class 买卖股票的最佳时机II {


    /**
     * 贪心选择，每次有利润就买卖
     * @param prices
     * @return
     */
    public int maxProfit(int[] prices) {

        int maxProfit = 0;
        for (int i = 0; i < prices.length-1; i++) {

            if (prices[i+1]-prices[i]>0){
                maxProfit = maxProfit+ (prices[i+1]-prices[i]);
            }

        }

        return maxProfit;
    }

}
